package com.mingke.auth.controller;

import com.mingke.auth.config.QiniuOSSUtils;
import com.mingke.common.service.UserService;
import com.mingke.common.transfer.LoginTO;
import com.mingke.common.transfer.RegisterTO;
import com.mingke.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 
 *
 * @author mingke
 * @email 1510181330@qq.com
 * @date 2021-12-17 14:25:08
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private QiniuOSSUtils ossUtils;

    @PostMapping("login")
    public String login(@RequestBody LoginTO loginTO) {
       return userService.login(loginTO);
    }

    @PostMapping("register")
    public String register(@RequestBody RegisterTO registerTO) {
        return userService.register(registerTO);
    }

    @GetMapping("oss")
    public R oss() {
        return R.ok().put("ossToken", ossUtils.SimpleUpload());
    }
}
